package top.yxqin.easymine.commands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import top.yxqin.easymine.PlayerData.PlayerData;
import top.yxqin.easymine.PlayerData.PlayerList;
import top.yxqin.easymine.unit.Message;

public class superdig implements CommandExecutor
{

    @Override
    public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label,
                             @NotNull String[] args)
    {
        if(sender instanceof Player)
        {
            if(label.equals("superdig"))
            {
                if(args.length==1)
                {
                    PlayerData mp= PlayerList.getPlayerData(sender.getName());
                    if(args[0].equals("true"))
                    {
                        mp.setCanSuperDig(true);
                        Message.sendInfo(sender,"开启超级挖掘功能");
                    }
                    else if(args[0].equals("false"))
                    {
                        mp.setCanSuperDig(false);
                        Message.sendInfo(sender,"关闭超级挖掘功能");
                    }
                    else
                        Message.sendError(sender,"Usage: /superdig <true/false>");

                }
                else
                {
                    Message.sendError(sender,"Usage: /supermine <true/false>");
                }

            }
        }
        else
            Message.sendError(sender, "该命令只能由玩家发出");

        return true;
    }
}
